import { usePinia } from "@/store";
import router from "@/router";
export function logout(before?: () => void, after?: () => void) {
  const useStore = usePinia();
  before && before();
  // 清除token
  localStorage.removeItem("token");
  // 清除路由
  useStore.routes.forEach((item) => router.removeRoute(item.name));
  // 清除pinia
  useStore.username = "";
  useStore.menus = [];
  // 跳转到login
  router.push("/login");
  // 调用callback
  after && after();
}
